home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wics.zip / DEMOWIN.CPP < prev    next >
C/C++ Source or Header  |  1993-02-19  |  7KB  |  232 lines

  1. //==============================================================================================
  2. //
  3. //    WICS Demonstration Application
  4. //    Version 1.00
  5. //
  6. //    DEMO.CPP main application code file
  7. //    February 1993
  8. //
  9. //    Copyright (C) 1993 Microdyne Development Technologies
  10. //
  11. //==============================================================================================
  12. //
  13. //    Abstract:
  14. //
  15. //
  16. //==============================================================================================        
  17.  
  18. #include <owl.h>
  19. #include <wics.h>
  20. #include <demorc.h>
  21. #include <demo.h>
  22. #include <eframe.h>
  23. #include <filewnd.h>
  24. #include <dedtwin.h>
  25. #include <smpldlg.h>
  26.  
  27. //----------------------------------------------------------------------------------------------
  28. //    Constructor for TDemoWindow
  29. //
  30. //    The TDemoWindow is the main frame window of the Line Information Database application. This
  31. //    window contains all user work areas as child windows.  The routine creates a speed bar (or
  32. //    Icon Bar) control, sets the child window list to item 1 of the default menu (this is the
  33. //    Window item) and records the active menu as the default menu for the application. The
  34. //    default menu for the application contains only three items, File, Window and Help. Once the
  35. //    application window is created, the Window item is removed from the main menu.
  36. //----------------------------------------------------------------------------------------------
  37.  
  38. TDemoWindow::TDemoWindow(LPSTR ATitle, int Menu) :
  39.         TExtendedMDIFrame(ATitle, Menu, TRUE, TRUE)
  40. {
  41.     ChildMenuPos = 3;
  42. }
  43.  
  44. //-------------------------------------------------------------------------------------
  45. //    Destructor for TDemoWindow
  46. //
  47. //    The destructor is called when the application terminates. All child windows are
  48. //    destroyed automatically.
  49. //-------------------------------------------------------------------------------------
  50.  
  51. TDemoWindow::~TDemoWindow()
  52. {
  53. }
  54.  
  55. //-------------------------------------------------------------------------------------
  56. //    SetupWindow
  57. //
  58. //  This routine calls the default windows setup procedure for frame windows
  59. //    (TExtendedMDIFrame::SetupWindow). Then, the routine locates and records the menu
  60. //    item handle for the Window entry in the main menu. The Window entry is then removed
  61. //    from the main menu.
  62. //
  63. //    Note:    The Window entry is not destroyed, it merely remains in memory to be added
  64. //            to the menu again at a later time. The Window entry holds the list of
  65. //            active child windows.
  66. //-------------------------------------------------------------------------------------
  67.  
  68. void TDemoWindow::SetupWindow ()
  69. {
  70.     int        rcd ;
  71.  
  72.     TExtendedMDIFrame::SetupWindow();
  73.  
  74.     GetStatusBar()->AppendArea(80, "Ready", 0x000080);
  75.  
  76.     SetIconBarStartPoint(4);
  77.     PlaceIconBarButton (IBID_FILEOPEN);
  78.     PlaceIconBarButton (IBID_FILESAVE);
  79.     InsertIconBarSpace();
  80.     PlaceFontSelectionControl(ID_FONTSELECT);
  81.     InsertIconBarSpace();
  82.     PlaceIconBarButton (IBID_UNDO);
  83.     PlaceIconBarButton (IBID_CUT);
  84.     PlaceIconBarButton (IBID_COPY);
  85.     PlaceIconBarButton (IBID_PASTE);
  86.     InsertIconBarSpace();
  87.     PlaceIconBarButton (IBID_BOLD, TRUE);
  88.     PlaceIconBarButton (IBID_ITALIC, TRUE);
  89.     InsertIconBarSpace();
  90.     PlaceIconBarButton (IBID_PRINTER);
  91.  
  92.     SetIconBarButtonCommandCode (IBID_FILEOPEN, CM_OPEN);
  93.     SetIconBarButtonCommandCode (IBID_FILESAVE, CM_FILESAVE);
  94.     SetIconBarButtonCommandCode (IBID_CUT, CM_EDITCUT);
  95.     SetIconBarButtonCommandCode (IBID_COPY, CM_EDITCOPY);
  96.     SetIconBarButtonCommandCode (IBID_PASTE, CM_EDITPASTE);
  97.     SetIconBarButtonCommandCode (IBID_UNDO, CM_EDITUNDO);
  98.     SetIconBarButtonCommandCode (IBID_BOLD, CM_BOLD);
  99.     SetIconBarButtonCommandCode (IBID_ITALIC, CM_ITALIC);
  100.     SetIconBarButtonCommandCode (IBID_PRINTER, CM_PRINT);
  101.  
  102.     SetFontFamilyCommandCode (CM_FONTCHANGED);
  103.     SetFontSizeCommandCode (CM_FONTSIZECHANGED);
  104.  
  105.     SetIconBarButtonState (IBID_LEFT, TRUE);
  106.     SetIconBarButtonState (IBID_CENTER, FALSE);
  107.     SetIconBarButtonState (IBID_RIGHT, FALSE);
  108.     SetIconBarButtonState (IBID_DECIMAL, FALSE);
  109. }
  110.  
  111. //-------------------------------------------------------------------------------------
  112. //    GetWindowClass
  113. //
  114. //    This routine retreives the default values for the window class. Then, the routine
  115. //    adds the LIDB_ICON to the class.
  116. //-------------------------------------------------------------------------------------
  117.  
  118. void TDemoWindow::GetWindowClass(WNDCLASS& WndClass)
  119. {
  120.     TExtendedMDIFrame::GetWindowClass( WndClass );
  121.     WndClass.hIcon = LoadIcon( GetApplication()->hInstance, MAKEINTRESOURCE(DEMO_ICON));
  122. }
  123.  
  124. void TDemoWindow::DefWndProc (RTMessage Msg)
  125. {
  126.     if ( Msg.Message == ((PTDemoApp)GetApplication())->idHelpMessage )
  127.         WMCommDlgHelp (Msg);
  128.     else
  129.         TExtendedMDIFrame::DefWndProc(Msg);
  130. }
  131.  
  132. void TDemoWindow::WMCommDlgHelp (RTMessage)
  133. {
  134. }
  135.  
  136. void TDemoWindow::CMHelpIndex (RTMessage)
  137. {
  138.     LPSTR    lpHelpFile = new char[128];
  139.  
  140.     lstrcpy ( lpHelpFile, "DEMO.HLP");
  141.  
  142.     WinHelp (HWindow, lpHelpFile, HELP_CONTENTS, 0L);
  143.  
  144.     delete lpHelpFile;
  145. }
  146.  
  147. void TDemoWindow::CMUsingHelp (RTMessage)
  148. {
  149.     LPSTR    lpHelpFile = new char[128];
  150.  
  151.     lstrcpy ( lpHelpFile, "DEMO.HLP");
  152.  
  153.     WinHelp (HWindow, lpHelpFile, HELP_HELPONHELP, 0L);
  154.  
  155.     delete lpHelpFile;
  156. }
  157.  
  158. void TDemoWindow::CMAbout (RTMessage)
  159. {
  160. }
  161.  
  162. void TDemoWindow::CMSampleDialog (RTMessage)
  163. {
  164.     GetModule()->ExecDialog( new TSampleDialog(this));
  165. }
  166.  
  167. void TDemoWindow::CMChooseColor (RTMessage)
  168. {
  169.     CHOOSECOLOR    cc;
  170.  
  171.     cc.lStructSize  = sizeof(CHOOSECOLOR);
  172.     cc.hwndOwner    = HWindow;
  173.     cc.hInstance    = GetApplication()->hInstance;
  174.     cc.rgbResult    = RGB(0,0,0);
  175.     cc.lpCustColors = rgbCustom;
  176.     cc.Flags        = CC_FULLOPEN | CC_SHOWHELP;
  177.  
  178.     ChooseColor (&cc);
  179. }
  180.  
  181. void TDemoWindow::CMOpen (RTMessage)
  182. {
  183.     int                i;
  184.     LPSTR            lpFilter;
  185.     OPENFILENAME    ofn;
  186.  
  187.     lpFilter = new char [80];
  188.  
  189.     lstrcpy (lpFilter, "All Files?*.*?ASCII Files?*.CSV?") ;
  190.  
  191.     for ( i = lstrlen(lpFilter) ; i > 0 ; i-- )
  192.         if ( *(lpFilter+i) == '?' )
  193.             *(lpFilter+i) = 0 ;
  194.  
  195.     ofn.lStructSize         = sizeof(OPENFILENAME);
  196.     ofn.hwndOwner           = HWindow;
  197.     ofn.hInstance           = GetApplication()->hInstance;
  198.     ofn.lpstrFilter         = lpFilter;
  199.     ofn.lpstrCustomFilter     = NULL;
  200.     ofn.nMaxCustFilter        = 0;
  201.     ofn.nFilterIndex        = 1;
  202.     ofn.lpstrFile            = new char[128];
  203.     ofn.nMaxFile            = 128;
  204.     ofn.lpstrFileTitle        = NULL;
  205.     ofn.nMaxFileTitle        = 0;
  206.     ofn.lpstrInitialDir        = "C:\\";
  207.     ofn.lpstrTitle            = "Open File";
  208.       ofn.Flags                = OFN_PATHMUSTEXIST | OFN_SHOWHELP | OFN_FILEMUSTEXIST ; 
  209.     ofn.nFileOffset            = 0;
  210.     ofn.nFileExtension        = 0;
  211.     ofn.lpstrDefExt            = "DAT";
  212.     ofn.lCustData            = NULL;
  213.     ofn.lpfnHook            = NULL;
  214.     ofn.lpTemplateName        = NULL;
  215.  
  216.     lstrcpy (ofn.lpstrFile, "");
  217.  
  218.     if ( GetOpenFileName (&ofn))
  219.     {
  220.         GetApplication()->MakeWindow (new TDemoEditWindow(this, ofn.lpstrFileTitle, ofn.lpstrFile));
  221.     }
  222.  
  223.     delete lpFilter;
  224. }
  225.  
  226. void TDemoWindow::CMNew (RTMessage)
  227. {
  228.     GetApplication()->MakeWindow (new TDemoEditWindow(this, NULL, NULL));
  229. }
  230.  
  231.  
  232.